import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

Vue.use(Router)

export const constantRouterMap = [
  { path: '/login',
    meta: { title: '登录', noCache: true },
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/features/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/features/401'),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/features/redirect')
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/home'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'index', affix: true, noCache: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'center',
        component: () => import('@/views/system/user/center'),
        name: '个人中心',
        meta: { title: '个人中心' }
      }
    ]
  },
  {
    path: '/preparation',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'analyze',
        component: () => import('@/views/script/analyze'),
        name: '脚本分析',
        meta: { title: '脚本分析' }
      }
    ]
  },
  {
    path: '/golive',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'package',
        component: () => import('@/views/golive/package'),
        name: '打包',
        meta: { title: '打包' }
      },
      {
        path: 'publish',
        component: () => import('@/views/golive/publish'),
        name: '发布',
        meta: { title: '发布' }
      },
      {
        path: 'alibabaPublishBusiness',
        component: () => import('@/views/golive/alibabaPublish/business'),
        name: '业务流程',
        meta: { title: '业务流程' }
      },
      {
        path: 'alibabaPublishTask',
        component: () => import('@/views/golive/alibabaPublish/task'),
        name: '任务发布',
        meta: { title: '任务发布' }
      },
      {
        path: 'rollback',
        component: () => import('@/views/golive/rollback'),
        name: '还原',
        meta: { title: '还原' }
      }
    ]
  }
]

export default new Router({
  mode: 'hash',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
